<?php
class Administrator_Model_Adv extends Administrator_Model_System{
	public function __construct() {
		$this->db = Zend_Registry::get ( 'vicdbsystem' );
		$this->lang = new Nguyen_language_system ();
	}
	public function GetAllAdv_position(){
		$sql = 'select * from adv_position';
		return $this->db->fetchAll($sql);
	}
	public function GetAdv_positionById($id){
		$sql = 'select * from adv_position where id = "'.$id.'"';
		return $this->db->fetchRow($sql);
	}
	public function GetPositionMinid(){
		$sql = 'select min(id) from adv_position ';
		$a= $this->db->fetchRow($sql);
		return $a['min(id)'];
	}
	public function GetPositionById($id){
		$sql = 'select name from adv_position where id = "'.$id.'"';
		return $this->db->fetchRow($sql);
	}
	public function insertAdv_position($name,$width,$height,$status)
	{
		$data = array('name' => $name ,'width'=> $width,'height' =>$height,'status'=>$status);
		$this->db->insert('adv_position',$data);
		return $this->db->lastInsertId();
		
	}
	public function updateAdv_position($id, $name,$width,$height) {
		$where = "id = '$id'";
		$data = array ('name' => $name, 'width'=>$width,'height' => $height);
		$this->db->update ( 'adv_position', $data, $where );
	}
	public function delAdv_position($id) {
		$where = "id =  '$id'";
		$this->db->delete ( 'adv_position', $where );
	}
	
	public function GetAllAdv_details(){
		$sql = 'select * from adv_details';
		return $this->db->fetchAll($sql);
	}
	public function GetAdv_detailsById($id){
		$sql = 'select * from adv_details where id = "'.$id.'"';
		return $this->db->fetchRow($sql);
	}
	public function insertAdv_details($name,$position,$ordering,$type,$content,$link,$status)
	{
		$data = array('name' => $name ,'position'=> $position,'ordering' =>$ordering,'type'=>$type,'content'=>$content,'link' =>$link,'status'=>$status);
		$this->db->insert('adv_details',$data);
		return $this->db->lastInsertId();
		
	}
	public function updateAdv_details($id, $name,$position,$ordering,$type,$content,$link) {
		$where = "id = '$id'";
		$data = array('name' => $name ,'position'=> $position,'ordering' =>$ordering,'type'=>$type,'content'=>$content,'link' =>$link);		
		$this->db->update ( 'adv_details', $data, $where );
	}
	public function delAdv_details($id) {
		$where = "id =  '$id'";
		$this->db->delete ( 'adv_details', $where );
	}
}